import 'package:flutter/material.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:mall/gen/r.dart';
import 'package:mall/utils/image_component/image_component.dart';

import 'fill_in_order_entity.dart';

part 'order_detail_entity.g.dart';

@JsonSerializable()
class OrderDetailEntity {
  OrderInfo? orderInfo;
  List<FillInOrderCheckedgoodslist>? orderGoods;

  @JsonKey(includeToJson: false, includeFromJson: false)
  Widget get orderStatusWidget {
    return ImageComponent(R.image.goodsDetailWaittingShouhuo.path,size: 24);
  }

  OrderDetailEntity({
    this.orderInfo,
    this.orderGoods,
  });

  factory OrderDetailEntity.fromJson(Map<String, dynamic> json) => _$OrderDetailEntityFromJson(json);

  Map<String, dynamic> toJson() => _$OrderDetailEntityToJson(this);
}

@JsonSerializable()
class OrderInfo {
  String? orderStatusText;
  String? consignee;
  String? address;
  String? addTime;
  String? orderSn;
  double? actualPrice;
  double? goodsPrice;
  String? mobile;
  double? couponPrice;
  int? id;
  double? freightPrice;
  OrderInfoHandleOption? handleOption;

  OrderInfo({
    this.orderStatusText,
    this.consignee,
    this.address,
    this.addTime,
    this.orderSn,
    this.actualPrice,
    this.goodsPrice,
    this.mobile,
    this.couponPrice,
    this.id,
    this.freightPrice,
    this.handleOption,
  });

  factory OrderInfo.fromJson(Map<String, dynamic> json) => _$OrderInfoFromJson(json);

  Map<String, dynamic> toJson() => _$OrderInfoToJson(this);
}

@JsonSerializable()
class OrderInfoHandleOption {
  bool? cancel;
  bool? confirm;
  bool? rebuy;
  bool? pay;
  bool? comment;
  bool? delete;
  bool? refund;

  OrderInfoHandleOption({
    this.cancel,
    this.confirm,
    this.rebuy,
    this.pay,
    this.comment,
    this.delete,
    this.refund,
  });

  factory OrderInfoHandleOption.fromJson(Map<String, dynamic> json) => _$OrderInfoHandleOptionFromJson(json);

  Map<String, dynamic> toJson() => _$OrderInfoHandleOptionToJson(this);
}

@JsonSerializable()
class OrderGood {
  int? productId;
  String? addTime;
  int? orderId;
  int? goodsId;
  String? goodsSn;
  String? updateTime;
  List<String>? specifications;
  int? number;
  String? picUrl;
  bool? deleted;
  double? price;
  int? comment;
  int? id;
  String? goodsName;

  OrderGood({
    this.productId,
    this.addTime,
    this.orderId,
    this.goodsId,
    this.goodsSn,
    this.updateTime,
    this.specifications,
    this.number,
    this.picUrl,
    this.deleted,
    this.price,
    this.comment,
    this.id,
    this.goodsName,
  });

  factory OrderGood.fromJson(Map<String, dynamic> json) => _$OrderGoodFromJson(json);

  Map<String, dynamic> toJson() => _$OrderGoodToJson(this);
}